<template>
	<view>
		<Header type="back" title="会员权益" />
		<view class="bg-f8ff w-100 ab left0 bottom0 rounded-right ov-hd-y" :class="'top'+toprpx">
			<scroll-view class="scroll-view_H top0 uni-scroll " scroll-y="true">
				
				<view class="w-100 px-2-6 py-4">
					
					<view v-for="(item,index) in equity_list" :key='item.id' class="ov-hd circle32 show0 mb-3">
						<view class="w-100 h380 pb-3 re bg-theme_3 f-c-c ov-hd">
							
							<image class="w750 ab top0 left0 z-99" src="../../../static/icon_equity_bg.png" />
							
							<ImageFile :url="item.thumbnail" className="w522 h679 top40 re z-999"/>
							<view v-if="item.id == 1" class="z-999 w94 h54 circle20 border font28 t-w f-c-c ab top26 left26">当前</view>
						</view>
						<view class="w-100 h110 f-b-c bg-white px-2-4 equity-li" @click="change_height(index)">
							<view class="t-20">
								<view class="font32 h32 f-y-c font600">{{item.title}}</view>
								<view class="font500 font21 f-y-c h30 pt-1">累计消费{{item.cumulativeConsumption}}元</view>
							</view>
							<HornMargin type="left-top" />
							<view class="font500 font21 f-y-c t-20">
								<text class="mr-05">权益说明</text>
								<image src="../../../static/icon_right_0.png" class="w24 h24"/>
							</view>
						</view>
						<view class="bg-white w-100 px-2-6 equity" :id="'equity_'+index" :style="{height: (item.state?item.height:0) +'px'}">
								<view class="w-100 bg-ccc h1"></view>
								<view class="font28 font500 t-20 py-3">权益说明</view>
								<richText :rich_text="item.content"></richText>
								<view class="w-100 h30"></view>
						</view>
					</view>
				</view>
				<view class="w-100 h60"></view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import HornMargin from "../../../components/horn_margin.vue"
	import Header from "../../../components/header.vue"
	import richText from "../../ticket/components/rich-text.vue"
	import ImageFile from "../../../components/img_file.vue"
	
	import {levelList} from "../../../api/user.js"
	
	export default {
		components: {
			Header,
			HornMargin,
			richText,
			ImageFile
		},
		data() {
			return {
				toprpx: 220,
				equity_list: []
			}
		},
		mounted() {
			this.toprpx = uni.getStorageSync("toprpx")
			this.get_equity()
		},
		methods: {
			async get_equity(){
				// const {code,body} = await levelList()
				// if(code==='0'){
				// 	let list = body.records || []
					 
				// 	 list.map(item =>{
				// 		 item.state = true
				// 	 })
					 
				// 	 this.equity_list = list
					 
				// 	setTimeout(()=>{
				// 		this.equity_list.map((item,index)=>{
				// 			this.set_rich_text_height(index)
				// 		})
				// 	},100)
				// }
			},
			set_rich_text_height(index){
				// 点击收起或关闭
				let info = uni.createSelectorQuery().select("#equity_"+index);
				info.boundingClientRect(data=> { //data - 各种参数
					this.equity_list[index].height = data.height 
					this.equity_list[index].state = false
				}).exec()
			},
			change_height(index){
				this.equity_list[index].state = !this.equity_list[index].state 
			},
		}
	}
</script>

<style lang="scss" scoped>
	.scroll-view_H {
		position: absolute;
		left: 0;
		bottom: 0;
		right: 0;
		z-index: 9;
		box-sizing: border-box;
	}
	.equity{
		position: relative;
		transition-property: height;
		transition-duration: .3s;
	}
	.equity-li{
		margin-top: -30rpx;
		border-radius: 0 32rpx 0 0;
		position: relative;
		z-index: 99999;
	}
	.border{
		border: 2rpx solid #8CFA3C;
	}
</style>
